package com.jzo2o.foundations.controller.operation;


import com.jzo2o.common.enums.EnableStatusEnum;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 区域服务管理相关的接口
 * </p>
 *
 * @author @88Ra
 * @since 2024-12-24
 */
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端-区域服务管理接口")
public class ServeController {
	@Resource
	private IServeService serveService;
	
	
	@GetMapping("/page")
	@ApiOperation("区域服务分页查询")
	public PageResult<ServeResDTO> page(ServePageQueryReqDTO servePageQueryReqDTO) {
		
		PageResult<ServeResDTO> page = serveService.page(servePageQueryReqDTO);
		return page;
	}
	
	@PostMapping("/batch")
	@ApiOperation("添加区域服务")
	public void batchAdd(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTOList) {
		serveService.batchAdd(serveUpsertReqDTOList);
		
	}
	
	@PutMapping("/{id}")
	@ApiOperation("修改价格")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
			@ApiImplicitParam(name = "price", value = "价格", required = true, dataTypeClass = BigDecimal.class)
	})
	public void update(@PathVariable("id") Long id,
	                   BigDecimal price) {
		
		serveService.update(id, price);
		
	}
	
	@PutMapping("/onSale/{id}")
	@ApiOperation("服务上架")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
	})
	public void onSale(@PathVariable("id") Long id) {
		serveService.onSale(id);
	}
	
	
	@DeleteMapping("{id}")
	@ApiOperation("删除区域服务")
	public void deleteRegionServe(@PathVariable("id")Long id){
	
		serveService.deleteRegionServe(id);
	
	
	}
	
	
	
	@PutMapping("/offSale/{id}")
	@ApiOperation("下架区域服务")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
	})
	public void offSale(@PathVariable("id")Long id){
		serveService.offSale(id);
		
	}
	
	@PutMapping("/onHot/{id}")
	@ApiOperation("区域服务设置热门")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
	})
	public void onHot(@NotNull(message = "id不能为空") @PathVariable("id")Long id){
		serveService.changeHot(id, EnableStatusEnum.ENABLE.getStatus());
		
		
	}
	
	@PutMapping("/offHot/{id}")
	@ApiOperation("区域服务取消热门")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
	})
	public void offHot(@NotNull(message = "id不能为空") @PathVariable("id")Long id){
		serveService.changeHot(id, EnableStatusEnum.DISABLE.getStatus());
		
		
	}
	
	
	
	
	
	
	
}
